
#include <iostream>
#include "hscuda_rasterdata.h"

int main()
{
    std::cout << "Test CUDA Raster!" << std::endl;

    int size_x = 4;
    int size_y = 5;

    hscuda::raster::RasterData<float> raster(size_x, size_y);

    std::cout << "raster: " << std::endl;
    std::cout << "- Size x: " << raster.view().sizeX() << std::endl;
    std::cout << "- Size y: " << raster.view().sizeY() << std::endl;
    std::cout << "- Row major: " << raster.view().isRowMajor() << std::endl;
    std::cout << "- pData: " << raster.view().pData() << std::endl;
    std::cout << std::endl;

    /* 拷贝构造函数(交出所有权) */
    std::cout << "Testing [ raster1 = raster; ]:" << std::endl;
    std::cout << " Before: raster.empty: " << raster.view().isEmpty() << std::endl;
    hscuda::raster::RasterData<float> raster1;
    raster1 = raster;
    std::cout << " After : raster.empty: " << raster.view().isEmpty() << std::endl;
    std::cout << std::endl;
    
    /* 拷贝构造函数(交出所有权) */
    std::cout << "Testing [ hscuda::raster::RasterData<float> raster2(raster1); ]:" << std::endl;
    std::cout << " Before: raster1.empty: " << raster1.view().isEmpty() << std::endl;
    hscuda::raster::RasterData<float> raster2(raster1);
    std::cout << " After : raster1.empty: " << raster1.view().isEmpty() << std::endl;
    std::cout << std::endl;

    /* 深拷贝(重新分配内存并进行数据拷贝) */
    std::cout << "Testing [ raster3.copyFrom(raster2); ]:" << std::endl;
    std::cout << " Before: raster2.empty: " << raster2.view().isEmpty() << std::endl;
    hscuda::raster::RasterData<float> raster3;
    raster3.copyFrom(raster2);
    std::cout << " After : raster2.empty: " << raster2.view().isEmpty() << std::endl;
    std::cout << std::endl;

    std::cout << "Done!" << std::endl;
    return 0;
}

